Thu Jun 19 17:04:53 2025

# cell chat results per condition
cellchat <- readRDS(params$cellchat_file)

1 Detected Cell-Cell Interactions

1.1 Interaction strength

1.1.1 Untreated

groupSize <- as.numeric(table(cellchat$Untreated@idents))
netVisual_circle(cellchat$Untreated@net$weight, vertex.weight = groupSize, 
                 weight.scale = T, label.edge= F, title.name = "Interaction weights/strength", 
                 vertex.label.cex = 1)

pdf(file = 'untreated.pdf', width = 10, height = 10)
netVisual_circle(cellchat$Untreated@net$weight, vertex.weight = groupSize, 
                 weight.scale = T, label.edge= F, title.name = "Interaction weights/strength", 
                 vertex.label.cex = 3.2, edge.width.max = 15)
dev.off()
## png 
##   2

1.1.2 DSS

groupSize <- as.numeric(table(cellchat$DSS@idents))
netVisual_circle(cellchat$DSS@net$weight, vertex.weight = groupSize, 
                 weight.scale = T, label.edge= F, title.name = "Interaction weights/strength")

pdf(file = 'DSS.pdf', width = 10, height = 10)
netVisual_circle(cellchat$DSS@net$weight, vertex.weight = groupSize, 
                 weight.scale = T, label.edge= F, title.name = "Interaction weights/strength",
                 vertex.label.cex = 3.2, edge.width.max = 15)
dev.off()
## png 
##   2

1.1.3 Recovery

groupSize <- as.numeric(table(cellchat$Recovery@idents))
pdf(file = 'recovery.pdf', width = 10, height = 10)
netVisual_circle(cellchat$Recovery@net$weight, vertex.weight = groupSize, 
                 weight.scale = T, label.edge= F, title.name = "Interaction weights/strength",
                 vertex.label.cex = 3.2, edge.width.max = 15)
dev.off()
## png 
##   2

1.2 As a heatmap

1.2.1 Untreated

netVisual_heatmap(cellchat$Untreated, color.heatmap = "Reds", measure = 'weight')

1.2.2 DSS

netVisual_heatmap(cellchat$DSS, color.heatmap = "Reds", measure = 'weight')

1.2.3 Recovery

netVisual_heatmap(cellchat$Recovery, color.heatmap = "Reds", measure = 'weight')

2 Pathways

2.1 L-R pair contributions

2.1.1 Untreated

obj <- cellchat$Untreated
paths <- obj@netP$pathways
netAnalysis_contribution(obj, signaling = paths)

2.1.2 DSS

obj <- cellchat$DSS
paths <- obj@netP$pathways
netAnalysis_contribution(obj, signaling = paths)

2.1.3 Recovery

obj <- cellchat$Recovery
paths <- obj@netP$pathways
netAnalysis_contribution(obj, signaling = paths)

2.2 Chord diagram

2.2.1 Untreated

obj <- cellchat$Untreated
netVisual_chord_gene(obj, slot.name = "netP", legend.pos.x = 10, lab.cex = 0.4)

2.2.2 DSS

obj <- cellchat$DSS
netVisual_chord_gene(obj, slot.name = "netP", legend.pos.x = 10, lab.cex = 0.4)

2.2.3 Recovery

obj <- cellchat$Recovery
netVisual_chord_gene(obj, slot.name = "netP", legend.pos.x = 10, lab.cex = 0.4)

## png 
##   2
## png 
##   2

3 Network Analysis

cellchat <- sapply(simplify = F, cellchat, function(obj) {
  netAnalysis_computeCentrality(obj, slot.name = "netP")
})

3.1 Outgoing signaling patterns

3.1.1 Untreated

obj <- cellchat$Untreated
netAnalysis_signalingRole_heatmap(obj, pattern = "outgoing", color.heatmap = 'Reds', 
                                  height = 15, width = 20)

3.1.2 DSS

obj <- cellchat$DSS
netAnalysis_signalingRole_heatmap(obj, pattern = "outgoing", color.heatmap = 'Reds', 
                                  height = 15, width = 20)

3.1.3 Recovery

obj <- cellchat$Recovery
netAnalysis_signalingRole_heatmap(obj, pattern = "outgoing", color.heatmap = 'Reds',
                                   height = 15, width = 20)

3.2 Incoming signaling patterns

3.2.1 Untreated

obj <- cellchat$Untreated
netAnalysis_signalingRole_heatmap(obj, pattern = "incoming", color.heatmap = 'Reds',
                                   height = 15, width = 20)

3.2.2 DSS

obj <- cellchat$DSS
netAnalysis_signalingRole_heatmap(obj, pattern = "incoming", color.heatmap = 'Reds',
                                   height = 15, width = 20)

3.2.3 Recovery

obj <- cellchat$Recovery
netAnalysis_signalingRole_heatmap(obj, pattern = "incoming", color.heatmap = 'Reds',
                                   height = 15, width = 20)

3.3 Incoming interaction patterns

nPatterns = 4
cellchat <- sapply(simplify = F, cellchat, function(obj) {
  identifyCommunicationPatterns(obj, pattern = "incoming", k = nPatterns, heatmap.show = F)
})

3.3.1 River Plot

3.3.1.1 Untreated

obj <- cellchat$Untreated
netAnalysis_river(obj, pattern = "incoming")

3.3.1.2 DSS

obj <- cellchat$DSS
netAnalysis_river(obj, pattern = "incoming")

3.3.1.3 Recovery

obj <- cellchat$Recovery
netAnalysis_river(obj, pattern = "incoming")

3.4 Outgoing interaction patterns

nPatterns = 4
cellchat <- sapply(simplify = F, cellchat, function(obj) {
  identifyCommunicationPatterns(obj, pattern = "outgoing", k = nPatterns, heatmap.show = F)
})

3.4.1 River Plot

3.4.1.1 Untreated

obj <- cellchat$Untreated
netAnalysis_river(obj, pattern = "outgoing")

3.4.1.2 DSS

obj <- cellchat$DSS
netAnalysis_river(obj, pattern = "outgoing")

3.4.1.3 Recovery

obj <- cellchat$Recovery
netAnalysis_river(obj, pattern = "outgoing")